﻿using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace CodePlex.Silverlight.Controls
{
    public static class Helpers
    {

        public static T FindParentOfType<T>(FrameworkElement ctrl)
        {
            if (ctrl.Parent != null)
            {
                if (ctrl.Parent.GetType() == typeof(T))
                {
                    return (T)ctrl.Parent;
                }
                return FindParentOfType<T>((FrameworkElement)ctrl.Parent);
            }
            return default(T);
        }

    }
}
